package de.kalinasch.pa.placereminder.database;

import android.content.Context;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper;
import android.util.Log;

public class DBManager extends SQLiteOpenHelper {

	private static final String DATENBANK_NAME = "placereminder.db";
	private static final int DATENBANK_VERSION = 1;

	public DBManager(Context _context) {

		super(_context, DATENBANK_NAME, null, DATENBANK_VERSION);
		Log.d("SQL", I_Incident.SQL_CREATE);
	}

	/**
	 * The method is called only once, the first time the database is created.
	 * 
	 * @param db
	 *            The database object
	 */
	@Override
	public void onCreate(SQLiteDatabase _db) {
		Log.d("SQL", "Second call " + I_Incident.SQL_CREATE);
		_db.execSQL(I_Incident.SQL_CREATE);
	}

	/**
	 * The method is called if the database getting changed (e.g. alter table
	 * xy).
	 * 
	 * @param _db
	 *            The database object
	 */
	@Override
	public void onUpgrade(SQLiteDatabase _db, int oldVersion, int newVersion) {
		_db.execSQL(I_Incident.SQL_AFTER_ALTER);
		onCreate(_db);
	}
}
